{{#if complianceAvailabilityTask.isRunning}}
  {{pendulum-ellipsis-animation}}
{{else}}
  {{#if isCompliancePolicyAvailable}}

    <div id="compliance" class="tab-body">
      {{#if _hasBadData}}
        <div class="alert alert-danger post-action-notification" role="alert">
          <p>
            Oops! We have discovered some issues with this Dataset's fields that
            may put any updates in an invalid state. <br>
            Unfortunately updates are <strong>disabled</strong> at this time. <br>
            Please shoot us an email at
            <a href="mailto:ask_metadata@linkedin.com">ask_metadata@linkedin.com</a>
            and we will get on this asap! <br>
            Our apologies.
          </p>
        </div>
      {{else}}
        <section class="action-bar">
          {{#if (and isEditing (not (eq editTarget ComplianceEdit.ExportPolicy)))}}

            <div class="container action-bar__content">

              {{#if showAdvancedEditApplyStep}}

                {{#track-ui-event category=trackableCategory.Compliance action=trackableEvent.Compliance.ManualApply
                                  name=editTarget as |metrics|}}
                  <button
                    class="nacho-button nacho-button--large-inverse action-bar__item"
                    title="Apply JSON"
                    onclick={{action metrics.trackOnAction (action "onApplyComplianceJson")}}
                    disabled={{isManualApplyDisabled}}>
                    Apply
                  </button>
                {{/track-ui-event}}

              {{else}}

                {{#track-ui-event category=trackableCategory.Compliance
                                  action=trackableEvent.Compliance.Save as |metrics|}}
                  <button
                    class="nacho-button nacho-button--large-inverse action-bar__item"
                    title="{{unless isDatasetFullyClassified
                                    'Ensure you have provided a yes/no value for all dataset tags'
                                    'Save'}}"
                    onclick={{action metrics.trackOnAction (action "saveCompliance")}} disabled={{and (eq editTarget ComplianceEdit.CompliancePolicy) changeSetNeedsReview}}>
                    Save
                  </button>
                {{/track-ui-event}}

              {{/if}}


              {{#track-ui-event category=trackableCategory.Compliance
                                action=trackableEvent.Compliance.Cancel as |metrics|}}
                <button
                  class="nacho-button nacho-button--large nacho-button--secondary action-bar__item"
                  onclick={{action metrics.trackOnAction (action "onCancel")}}>
                  Cancel
                </button>
              {{/track-ui-event}}

              {{#if (and (eq editTarget ComplianceEdit.CompliancePolicy) (and manualParseError (not showGuidedComplianceEditMode)))}}
                <div class="action-bar__content__error-messages">
                  {{fa-icon "times-circle-o"}}

                  <span class="dataset-compliance-fields__manual-entry-errors">
                    {{manualParseError}}
                  </span>
                </div>
              {{/if}}
            </div>

          {{/if}}
        </section>
      {{/if}}

      {{#if (or isReadOnly (eq editTarget ComplianceEdit.ExportPolicy))}}
        {{datasets/compliance/export-policy
          exportPolicyData=exportPolicy
          isEditing=isEditing
          wikiLinks=@wikiLinks
          toggleEditing=(action toggleEditing)
          onSaveExportPolicy=(action "saveExportPolicy")}}
      {{/if}}

      {{#if (or isReadOnly (eq editTarget ComplianceEdit.PurgePolicy))}}
        {{#if getPlatformPoliciesTask.isRunning}}
          {{pendulum-ellipsis-animation}}
        {{/if}}

        {{#if getPlatformPoliciesTask.last.isError}}
          {{!--todo: swap out with error-state component--}}
          {{empty-state
            heading="Purge Policies not available"
            subHead="Could not find supported purge policies for this platform"
          }}

          <div class="purge-policy-list__retry-platforms">
            <button
              class="nacho-button nacho-button--large-inverse"
              onclick={{perform getPlatformPoliciesTask}}>
              Retry
            </button>
          </div>

        {{/if}}

        {{#if getPlatformPoliciesTask.last.isSuccessful}}
          <section class="metadata-prompt">
            <header class="metadata-prompt__header">
              <p>
                Compliance Purge Policy

                {{more-info
                  link=@wikiLinks.purgePolicies
                  tooltip="Click for more information Purge Policies"
                }}
              </p>

              {{#unless isEditing}}
                <div class="compliance-entities-meta__secondary">
                  <button
                    class="nacho-button nacho-button--tertiary"
                    onclick={{action toggleEditing true ComplianceEdit.PurgePolicy}}>

                    <i class="fa fa-pencil" aria-label="Edit Compliance Policy"></i>

                    Edit
                  </button>
                </div>
              {{/unless}}
            </header>

            <section>
              <div class="last-saved-by-container last-saved-by-container--no-padding">
                {{last-saved-by actor=retentionPolicy.modifiedBy time=retentionPolicy.modifiedTime}}
              </div>
            </section>
          </section>

          {{purge-policy
            isEditable=(not isReadOnly)
            platform=platform
            missingPolicyText="This dataset does not have a current compliance purge policy."
            supportedPurgePolicies=supportedPurgePolicies
            purgeNote=retentionPolicy.purgeNote
            purgePolicy=(readonly retentionPolicy.purgeType)
            onPolicyChange=(action "onDatasetPurgePolicyChange")
          }}

        {{/if}}
      {{/if}}

      {{#if schemaless}}

        {{#if (or isReadOnly (eq editTarget ComplianceEdit.DatasetLevelPolicy))}}
          {{datasets/schemaless-tagging
            classificationHelpLink=@wikiLinks.dht
            isEditing=isEditing
            classification=(readonly complianceInfo.confidentiality)
            containsPersonalData=(readonly complianceInfo.containingPersonalData)
            toggleEditing=(action toggleEditing)
            onClassificationChange=(action "onDatasetSecurityClassificationChange")
            onPersonalDataChange=(action "onDatasetLevelPolicyChange")
            onSaveCompliance=(action "saveCompliance")
            resetCompliance=(action "resetCompliance")
          }}
        {{/if}}

      {{else}}

        {{#if (or isReadOnly (eq editTarget ComplianceEdit.CompliancePolicy))}}
          {{#datasets/compliance/schema-entities
            isEditing=(readonly isEditing)
            wikiLinks=(readonly wikiLinks)
            fieldReviewOption=(readonly fieldReviewOption)
            foldedChangeSet=(readonly foldedChangeSet)
            unspecifiedTags=(readonly unspecifiedTags)
            complianceInfo=complianceInfo
            setUnspecifiedTagsAsNoneTask=setUnspecifiedTagsAsNoneTask
            toggleEditing=(action toggleEditing)
            showGuidedEditMode=(action "onShowGuidedEditMode")
            fieldReviewChange=(action "onFieldReviewChange")}}
            {{partial "datasets/dataset-compliance/dataset-compliance-entities"}}
          {{/datasets/compliance/schema-entities}}

        {{/if}}

      {{/if}}
    </div>

  {{else}}

    {{empty-state
      heading="Compliance Policy not available"
      subHead="Compliance Policy is currently not available for this platform"
    }}

  {{/if}}
{{/if}}
